import {Space, Table, TableProps, Tag} from "antd";
import {logger} from "@umijs/utils";
interface DataType{
    key:string,
    name:string,
    age:number,
    address:string,
    tags?:string[]
}
function Table02(){

    const dataSource:DataType[] = [
        {
            key: '1',
            name: '胡彦斌',
            age: 32,
            address: '西湖区湖底公园1号',
            tags:["java","python"]
        },
        {
            key: '2',
            name: '胡彦祖',
            age: 42,
            address: '西湖区湖底公园1号',
            tags:["c++","javascript"]
        },
    ];

    const columns:TableProps<DataType>["columns"] = [
        {
            title: '姓名',
            dataIndex: 'name',
            key: 'name',
            render:(text)=> <a>{text}hehe</a>
        },
        {
            title: '年龄',
            dataIndex: 'age',
            key: 'age',
        },
        {
            title: '住址',
            dataIndex: 'address',
            key: 'address',
        },
        {
            title: 'tags',
            dataIndex: 'tags',
            key: 'tags',
            render:(_,{tags})=>{

                console.log(_,tags,"tags")
                return (
                    <>

                        {
                            tags?.map((tag,index)=>{
                                return (<Tag key={index}> {tag?.toUpperCase()}</Tag>)
                            })
                        }
                    </>
                )
            }
        },
        {
            title: 'action',
            key: 'action',
            render:(_,record)=>{
                console.log(_,record,"record")
                return (
                    <Space>
                        <a href="">invite {record.name}</a>
                        <a href="">delete</a>
                    </Space>
                )
            }
        },
    ];

    return <Table dataSource={dataSource} columns={columns} />;
}

export default Table02
